package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@SuppressWarnings("ALL")
/**
 * @Description :
 * @author     :LD
 */
public interface CheckGroupMapper extends BaseMapper<CheckGroup> {
    @Insert("insert into t_checkgroup_checkitem values(#{id},#{itemId})")
    void addCheckGroupAndCheckItemIds(@Param("id")Integer id, @Param("itemId")Integer itemId);

    @Select("select CHECKITEM_ID  from t_checkgroup_checkitem where CHECKGROUP_ID = #{id}")
    int[] findItemByGroupId(Integer id);

    @Delete("delete from t_checkgroup_checkitem where CHECKGROUP_ID=#{id}")
    void deleteByGroupId(Integer id);

    @Select("select i.name from t_checkitem i,t_checkgroup_checkitem g where g.checkitem_id=i.id and i.is_delete=0 and g.checkgroup_id=#{id}")
    List<CheckItem> findCheckItemsByGroupId(Integer id);
}
